

const express = require("express")

const apiRouter = require("./apiRouter.js")


const initRouter = require("./initRouter.js")

const app = express()



app.use("/", express.static("public"))

app.set("views", "./views")
app.set("view engine", "ejs")


app.use(express.urlencoded({ extended: false }))
app.use(express.json())


app.use("/", initRouter)

app.use("/api", apiRouter)

//错误中间件
app.use((req, res) => {


    res.status(500).send('服务器错误!');
});


app.listen(3000, () => {


    console.log("服务器启动了");

})


